home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / News / Alexandra.0.82 / Source / AMGErrorHandling.subproj / EMErrorObserver.m < prev    next >
Encoding:
Text File  |  1996-01-30  |  1.9 KB  |  97 lines

  1.  
  2. #import "EMErrorManager.h"
  3. #import "EMErrorObserver.h"
  4. #import <appkit/appkit.h>
  5.  
  6. @implementation EMErrorObserver
  7.  
  8. //--------------------------------------------------------------------------------
  9. // INIT & FREE
  10. //--------------------------------------------------------------------------------
  11.  
  12. - initWith:anObj andSelector:(SEL)aSel;
  13.     {
  14.     [super init];
  15.     [self setObserver:anObj andSelector:aSel];
  16.     return self;
  17.     }
  18.     
  19.  
  20. - free;
  21.     {
  22.     return [super free];
  23.     }
  24.     
  25.  
  26. //--------------------------------------------------------------------------------
  27. // I-VAR
  28. //--------------------------------------------------------------------------------
  29.  
  30. - setObserver:anObj andSelector:(SEL)aSel;
  31.     {
  32.     Method        method;
  33.     const char    *type;
  34.     int            d;
  35.         
  36.     if(![anObj respondsTo:aSel])
  37.         EM_ERROR(EM_INTBASE+10,sel_getName(aSel),NULL);
  38.  
  39.     method=class_getInstanceMethod([anObj class],aSel);
  40.     if(!method)
  41.         method=class_getClassMethod([anObj class],aSel);
  42.     if(!method)
  43.         EM_ERROR(EM_INTBASE+13,NULL,NULL);
  44.     switch(method_getNumberOfArguments(method))
  45.         {
  46.     case 2:
  47.         wantsInfoObject=NO;
  48.         break;
  49.     case 3:
  50.         method_getArgumentInfo(method,2,&type,&d);
  51.         if(type[0]==_C_ID)
  52.             wantsInfoObject=YES;
  53.         else
  54.             EM_ERROR(EM_INTBASE+11,sel_getName(aSel),NULL);
  55.         break;
  56.     default:
  57.         EM_ERROR(EM_INTBASE+11,sel_getName(aSel),NULL);
  58.         }
  59.     observer=anObj;
  60.     selector=aSel;
  61.     return self;
  62.     }
  63.  
  64.  
  65. - observer;
  66.     {
  67.     return observer;
  68.     }
  69.  
  70.  
  71. - (SEL)selector;
  72.     {
  73.     return selector;
  74.     }
  75.     
  76.     
  77. //--------------------------------------------------------------------------------
  78. // DISPATCH MESSAGE TO OBSERVER
  79. //--------------------------------------------------------------------------------
  80.  
  81. - (void)dispatch:(EMErrorInfo *)object;
  82.     {
  83.     if(wantsInfoObject)
  84.         [observer perform:selector with:object];
  85.     else
  86.         [observer perform:selector];
  87.     }
  88.  
  89.  
  90. //--------------------------------------------------------------------------------
  91. // THAT'S IT
  92. //--------------------------------------------------------------------------------
  93.  
  94. @end
  95.  
  96.  
  97.